package com.mew.game.strategy;

import com.mew.common.dc.db.ProfileService;
import com.mew.common.entity.user.Profile;
import com.mew.common.vo.LevelVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class UserProfileDataSupport {

    @Autowired
    private ProfileService profileService;

    public Profile persistentProfile(long userId, long betNumber, long paymentNumber, LevelVO levelVO){

        Profile profile = profileService.getRedisProfileById(userId);
        Profile other = new Profile();
        other.setUserId(profile.getUserId());
        long winNumber =  paymentNumber - betNumber;
        other.setGoldNumber(winNumber);
        profile.setGoldNumber(profile.getGoldNumber() + winNumber);
        profileService.updateProfile(profile, other);
        return profile;
    }



}
